<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang='en'>
  <head>
    <title>KRPC::StreamConnection</title>
    <meta content='text/html; charset=UTF-8' http-equiv='Content-Type'>
    <link href='../../css/style.css' media='screen' rel='stylesheet' type='text/css'>
    <script type='text/javascript'>
      //<![CDATA[
        function popupCode(url) {
          window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
        }
        
        function toggleCode(id) {
          var code = document.getElementById(id)
        
          code.style.display = code.style.display != 'block' ? 'block' : 'none'
          return true
        }
        
        // Make codeblocks hidden by default
        document.writeln('<' + 'style type="text/css">.method .source pre { display: none }<\/style>')
      //]]>
    </script>
  </head>
  <body class='page'>
    <div class='class' id='wrapper'>
      <div class='header'>
        <h1 class='name'>
          <span class='type'>class</span>
          KRPC::StreamConnection
        </h1>
        <ol class='paths'>
          <li>
            <a target="docwin" href="../../files/lib/krpc/connection_rb.html">lib/krpc/connection.rb</a>
          </li>
        </ol>
        <div class='parent'>
          Superclass:
          <strong><a target="docwin" href="Connection.html">Connection</a></strong>
        </div>
      </div>
      <div id='content'>
        <div id='text'>
          <div id='description'>
            
            <p>TCP connection for streaming.</p>
          </div>
          <div id='method-list'>
            <h2>Methods</h2>
            <h3>Public Class</h3>
            <ol>
              <li><a target="docwin" href="#method-c-new">new</a></li>
            </ol>
            <h3>Public Instance</h3>
            <ol>
              <li><a target="docwin" href="#method-i-handshake">handshake</a></li>
              <li><a target="docwin" href="#attribute-i-rpc_connection">rpc_connection</a></li>
            </ol>
          </div>
          <div id='context'>
          </div>
          <div id='section'>
            <div id='attribute-list'>
              <h2 class='section-bar'>Attributes</h2>
              <div class='name-list'>
                <table>
                  <tr class='top-aligned-row context-row'>
                    <td class='context-item-name'>
                      <a name='attribute-i-rpc_connection'>rpc_connection</a>
                    </td>
                    <td class='context-item-value'>[R]</td>
                    <td class='context-item-desc'></td>
                  </tr>
                </table>
              </div>
            </div>
            <div id='methods'>
              <h2>Public Class methods</h2>
              <div class='method public-class' id='method-method-c-new'>
                <a name='method-c-new'></a>
                <div class='synopsis'>
                  <span class='name'>new</span>
                  <span class='arguments'>(rpc_connection, host = DEFAULT_SERVER_HOST, port = DEFAULT_SERVER_STREAM_PORT)</span>
                </div>
                <div class='description'>
                  
                </div>
                <div class='source'>
                  <a class='source-toggle' href='#' onclick="toggleCode('method-c-new-source'); return false">
                    [show source]
                  </a>
                  <pre id='method-c-new-source'><span class="ruby-comment"># File lib/krpc/connection.rb, line 103</span>&#x000A;<span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">rpc_connection</span>, <span class="ruby-identifier">host</span> = <span class="ruby-constant">DEFAULT_SERVER_HOST</span>, <span class="ruby-identifier">port</span> = <span class="ruby-constant">DEFAULT_SERVER_STREAM_PORT</span>)&#x000A;  <span class="ruby-keyword">super</span> <span class="ruby-identifier">host</span>, <span class="ruby-identifier">port</span>&#x000A;  <span class="ruby-ivar">@rpc_connection</span> = <span class="ruby-identifier">rpc_connection</span>&#x000A;<span class="ruby-keyword">end</span></pre>
                </div>
              </div>
              <h2>Public Instance methods</h2>
              <div class='method public-instance' id='method-method-i-handshake'>
                <a name='method-i-handshake'></a>
                <div class='synopsis'>
                  <span class='name'>handshake</span>
                  <span class='arguments'>()</span>
                </div>
                <div class='description'>
                  
                  <p>Perform handshake with kRPC server, sending <code>client_id</code>
                  retrieved from <code>rpc_connection</code>.</p>
                </div>
                <div class='source'>
                  <a class='source-toggle' href='#' onclick="toggleCode('method-i-handshake-source'); return false">
                    [show source]
                  </a>
                  <pre id='method-i-handshake-source'><span class="ruby-comment"># File lib/krpc/connection.rb, line 109</span>&#x000A;<span class="ruby-keyword">def</span> <span class="ruby-identifier">handshake</span>&#x000A;  <span class="ruby-identifier">raise</span>(<span class="ruby-constant">ConnectionError</span>, <span class="ruby-string">&quot;RPC connection must obtain client_id before stream connection can perform valid handshake - closing stream connection&quot;</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">rpc_connection</span>.<span class="ruby-identifier">client_id</span>.<span class="ruby-identifier">nil?</span> &#x000A;  <span class="ruby-identifier">send</span> <span class="ruby-constant">Encoder</span><span class="ruby-operator">::</span><span class="ruby-constant">STREAM_HELLO_MESSAGE</span>&#x000A;  <span class="ruby-identifier">send</span> <span class="ruby-identifier">rpc_connection</span>.<span class="ruby-identifier">client_id</span>&#x000A;  <span class="ruby-identifier">resp</span> = <span class="ruby-identifier">recv</span> <span class="ruby-constant">Decoder</span><span class="ruby-operator">::</span><span class="ruby-constant">OK_LENGTH</span>&#x000A;  <span class="ruby-identifier">raise</span> <span class="ruby-constant">ConnectionError</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">resp</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Decoder</span><span class="ruby-operator">::</span><span class="ruby-constant">OK_MESSAGE</span>&#x000A;<span class="ruby-keyword">end</span></pre>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div id='footer-push'></div>
    </div>
    <div id='footer'>
      <a target="docwin" href="http://github.com/mislav/hanna/tree/master"><strong>Hanna</strong> RDoc template</a>
    </div>
  </body>
</html>
